package io.github.wslxm.springbootplus2.core.result;

import com.baomidou.mybatisplus.annotation.IEnum;
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
 * 异常常量类
 *
 * @author ws
 * @mail 1720696548@qq.com
 * @date 2020/2/9 0009 11:16
 * @return
 */
@Getter
@NoArgsConstructor
public enum ResultType implements IEnum {

    // 系统相关 - 服务器内置状态码
    SYS_SUCCESS(200, "system.success"),
    SYS_SUCCESS_DELETE(200, "system.del_success"),
    SYS_SUCCESS_FIND(200, "system.find_success"),
    SYS_SUCCESS_INSERT(200, "system.add_success"),
    SYS_SUCCESS_UPDATE(200, "system.upd_success"),
    // 状态码错误
    SYS_ERROR_403(403, "system.403"),
    SYS_ERROR_404(404, "system.404"),
    SYS_ERROR_500(500, "system.500"),
    // 自定义异常统一错误码
    SYR_ERROR(9001, "system.error"),
    // DB 错误
    DB_EXECUTE_SQL_ERROR(9994, "system.db.sql_execute_error"),
    DB_OUT_OF_SIZE(9995, "system.db.field_max_size"),
    DB_FIELD_MISSING(9996, "system.db.field_missing"),
    DB_PRIMARY_REPEAT(9997, "system.db.primary_repeat"),

    // 参数错误 网关层 + sql 层 [9901-9999]
    PARAM_FIELD_MAX_LEN(9999, "system.param.field_max_size"),
    PARAM_MISSING(9999, "system.param.missing"),
    PARAM_ERROR(9999, "system.param.error"),

    // 权限认证,注意，前端需拦截所有为10000的返回重定向到登录页
    // 网关层 [10000-10999]
    // 登录相关特殊错误码
    GATEWAY_LOGIN_EXPIRED(10000, "system.gateway.login_expired"),
    GATEWAY_NO_TOKEN(10001, "system.gateway.no_token"),
    GATEWAY_JWT_PARSING_ERROR(10002, "system.gateway.jwt_parsing_error"),
    GATEWAY_JWT_SIGN_ERROR(10003, "system.gateway.jwt_sign_error"),
    GATEWAY_DISABLE(10004, "system.gateway.disable"),
    GATEWAY_BLACK_LIST_IP(10006, "system.gateway.black_list_ip"),
    GATEWAY_WHITE_LIST_NO_IP(10007, "system.gateway.white_list_no_ip"),
    GATEWAY_CURRENT_LIMIT(10008, "system.gateway.current_limit"),
    GATEWAY_IS_NO_SIGN(10010, "system.gateway.sign_not"),
    GATEWAY_SIGN_ERROR(10011, "system.gateway.sign_error"),
    GATEWAY_TIME_OUT(10012, "system.gateway.sign_timeout"),
    // 文件相关
    FILE_DISABLE_FORMAT(8009, "file1.upload.disable_format"),
    FILE_UPLOAD_EXISTS(8010, "file1.upload.fail_exists"),
    FILE_URL_NO_VISIT(8011, "file1.url.no_visit"),
    FILE_UPLOAD_FAIL(500, "file1.upload.fail"),
    FILE_UPLOAD_SUCCESS(200, "file1.upload.success"),
    // 用户相关
    USER_ACCOUNT_REPEAT(8001, "sys.user.account.repeat"),
    USER_NO_MENU(8002, "sys.user.menus.NotNull"),
    USER_PASSWORD_ERROR(8003, "sys.user.old_password.error"),
    USER_PHONE_IS_DUPLICATE(8004, "sys.user.phone.repeat"),
    // base
    BASE_CODE_REPEAT(8005, "sys.base.code.repeat"),
    BASE_NO_REQ_PARAM(8006, "sys.base.no_req_param"),
    BASE_NO_RESP_DATA(8007, "sys.base.no_resp_data"),

    ;
    private Integer value;
    private String msg;

    ResultType(Integer value, String msg) {
        this.value = value;
        this.msg = msg;
    }
}
